import socket

def handle_request(client_socket):
    request = client_socket.recv(1024)
    print(request.decode())

    response = b"HTTP/1.1 200 OK\r\n\r\nHello, world!"
    client_socket.send(response)
    client_socket.close()

def run_server():
    server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    server_socket.bind(('localhost', 8000))
    server_socket.listen(5)

    print("Starting server on port 8000...")

    while True:
        client_socket, address = server_socket.accept()
        handle_request(client_socket)

run_server()
